begin_time=$(date +%s)


echo "\033[34mAuto install atom plugins. Ver1.0 By NS"
echo "This tool can install atom plugins from github repo directly.Maybe it can makes your work finish quickly...\033[0m"

addr=$1
while [ -z $addr ] ;do
	echo -n "Please input git repo address of the plugin:"
	read addr
done
cd /home/ns/.atom/packages
echo "\033[32mYour plugin repo is : $addr\033[0m"
proxychains git clone $addr
path=`echo $addr | awk -F "/" '{print $NF}'`
cd /home/ns/.atom/packages/$path
npm install
if [ $? -eq 0 ] ;then
	echo "\033[32mDONE...\033[0m"
else
	echo "\033[31mError...\033[0m"
fi

end_time=$(date +%s)
cost=$(($end_time - $begin_time))
echo "Spend time:${cost}s"
